package com.hema.auction.widget.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hema.auction.R;
import com.hema.auction.utils.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author by john
 */

public class DetailPrice extends LinearLayout {


    @BindView(R.id.tv_now_price)
    TextView tvNowPrice;
    @BindView(R.id.tv_markt_price)
    TextView tvMarktPrice;
    @BindView(R.id.tv_time_tips)
    TextView tvTimeTips;
    @BindView(R.id.tv_time)
    TextView tvTime;

    public void setDetailPrice(FloatDetailPrice detailPrice) {
        this.detailPrice = detailPrice;
    }

    private FloatDetailPrice detailPrice;

    public DetailPrice(Context context) {
        super(context);
        init();
    }

    public DetailPrice(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public DetailPrice(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private void init() {
        ButterKnife.bind(this, LayoutInflater.from(getContext()).inflate(R.layout.layout_commodity_detail_price, this));
    }


    public void setNowPrice(String nowPrice) {
        tvNowPrice.setText(nowPrice);
        detailPrice.setNowPrice(nowPrice);
    }

    public void setMarktPrice(String marktPrice) {
        tvMarktPrice.setText(marktPrice);
        detailPrice.setMarktPrice(marktPrice);
    }


    public void setTime(String time) {
        tvTime.setText(time);
        detailPrice.setTime(time);
    }

    public void setAuctionEnd() {
        tvTimeTips.setText(getContext().getString(R.string.auction_end));
        setTime(Utils.countDown(0));
        detailPrice.setAuctionEnd();
    }

    public void setAuctionStart() {
        tvTimeTips.setText(getContext().getString(R.string.distance_end));
        detailPrice.setAuctionStart();
    }

    @OnClick({})
    public void onClick(View v) {
    }


}
